<template>
  <div>
    <span>公告标题 :</span>
    <input type="text" placeholder="请输入公告题目" v-model="title" /><br /><br />
    <span>公告内容：</span> <br /><b /><textarea
      name=""
      id=""
      cols="92"
      rows="10"
      placeholder="请输入公告内容"
      v-model="content"
    ></textarea>
    <div class="footer">
      
      <el-button type="primary" round @click="handleAdd()">发布公告</el-button>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { addnoticePost } from '../../../../request/noticeHttp'
const title = ref()
const content = ref()
const user_id = ref(2)
function handleAdd() {
  if (!title.value || !content.value) {
    alert('请填写完整信息')
    retur
  }
  addnoticePost(user_id.value, title.value, content.value)
    .then((res) => {
      // console.log(res)
      alert('发布成功')
      // dialogVisibleBuild.value=false
      title.value = ''
      content.value = ''
    })
    .catch((err) => {
      // console.log(err)
      alert('发布失败')
    })
}
</script>

<style lang="less" scoped>
input {
  margin: 0 20px;
  padding: 0 20px;
  // width: 500px;
  width: 70%;
  height: 30px;
  border-radius: 10px;
}
textarea {
  width: 90%;
  margin-top: 20px;
  padding: 20px;
  border-radius: 10px;
}
.footer {
  margin-top: 20px;
  margin-left: 85%;
}
</style>
